package com.bl.weilan.manager.controller.companytrade;

import com.bl.weilan.common.ApiResponseBody;
import com.bl.weilan.manager.controller.BaseController;
import com.bl.weilan.service.biz.companystockholder.CompanyStockholderService;
import com.bl.weilan.service.biz.companytrade.CompanyTradeService;
import com.bl.weilan.service.vo.DelBody;
import com.bl.weilan.service.vo.DelListBody;
import com.bl.weilan.service.vo.companystockholder.CompanyStockholderListVo;
import com.bl.weilan.service.vo.companytrade.CompanyTradeAddVo;
import com.bl.weilan.service.vo.companytrade.CompanyTradeListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


@RestController
@Log4j2
@RequestMapping(value = {"/weilan/manager/companytrade"})
@Api(value = "公司行业关联信息", description = "公司行业关联信息")
public class CompanyTradeController extends BaseController {
    @Autowired
    CompanyTradeService companyTradeService;

    @ApiOperation(value = "根据公司id获取公司的行业信息", notes = "根据公司id获取公司的行业信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "query", dataType = "String", defaultValue = "")})
    @GetMapping(value = {"/get_list"})
    public ApiResponseBody<CompanyTradeListVo> companysTradeList(
            @RequestParam(value = "companyId", required = true, defaultValue = "") String companyId,
            HttpServletRequest request) {
        CompanyTradeListVo companyTradeListVo = companyTradeService.getListByCompanyId(companyId);

        return ApiResponseBody.createSuccessBody(companyTradeListVo);
    }

    @ApiOperation(value = "增加公司行业关联信息", notes = "增加公司行业关联信息 ")
    @ApiImplicitParams({})
    @PostMapping(value = {"/add"})
    public ApiResponseBody add(
            @Valid @RequestBody CompanyTradeAddVo body, BindingResult result,
            HttpServletRequest request) {

        ApiResponseBody validResult = validParams(result);
        if (validResult != null) {
            return validResult;
        }

        companyTradeService.addCompanyTrade(body);

        return ApiResponseBody.createSuccessBody(null);
    }


    @ApiOperation(value = "删除公司行业关联信息", notes = "删除公司行业关联信息 ")
    @ApiImplicitParams({
    })
    @PostMapping(value = {"/del"})
    public ApiResponseBody del(
            @Valid @RequestBody DelBody body, BindingResult result,
            HttpServletRequest request) {

        companyTradeService.del(body);

        return ApiResponseBody.createSuccessBody(null);
    }

//    @ApiOperation(value = "批量删除公司行业关联信息", notes = "批量删除公司行业关联信息 ")
//    @ApiImplicitParams({
//    })
//    @PostMapping(value = {"/del_list"})
//    public ApiResponseBody delList(
//            @Valid @RequestBody DelListBody body, BindingResult result,
//            HttpServletRequest request) {
//
//        companyTradeService.delList(body);
//
//        return ApiResponseBody.createSuccessBody(null);
//    }
}
